home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_400 / 427_01 / multijoy.doc < prev    next >
Encoding:
Text File  |  1994-03-23  |  10.5 KB  |  264 lines

  1. The Multi Joystick Interface
  2. ============================
  3.  
  4. The Multi Joystick Interface is, as you probably already know, a device to
  5. connect six digital joysticks to your personal computer. This file desribes
  6.  
  7. a) how to configure MULTIJOY for your computer
  8. b) how the hardware of the interface works
  9. c) how use the interface with your own programs
  10. d) how to use the MULTIJOY and MINIJOY modules with your own programs
  11. e) details of the emulation of joysticks using the keyboard
  12. f) how to contact us
  13. g) how to get the multijoy games
  14. h) credits
  15.  
  16.  
  17. a) How to configure MULTIJOY for your computer
  18. ----------------------------------------------
  19.  
  20. All information MULTIJOY needs is to be stored in DOS environment variables.
  21. This way, you only have to configure MULTIJOY once and all games will run fine
  22. without configuring them individually. These environment variables are:
  23.  
  24. MULTICFG     tells MULTIJOY which config file to use. Config files store
  25.              information about the hardware of your specific interface. There's
  26.              also a file named KEYBOARD.CFG that puts MULTIJOY into joystick
  27.              emulation mode.
  28.  
  29. MULTIPATH    tells MULTIJOY where on your disk to look for the config file.
  30.  
  31. MULTIPORT    tells MULTIJOY which printer port the interface is connected to.
  32.              MULTIPORT is optional, if you don't set it, MULTIJOY uses the
  33.              first printer port.
  34.  
  35. MULTIDELAY   Don't care about this variable. Your TTL-based interface will work
  36.              well without setting it. However, some of the early, CMOS-based
  37.              interfaces are slower, so the computer has to wait for them. As
  38.              the speed of computers is steadily increasing, in times to come
  39.              MULTIDELAY may be of more importance.
  40.  
  41.              MULTIDELAY is optional, too. It states the number of NOPs that
  42.              will be executed in a tight loop between setting the printer port
  43.              and reading it.
  44.  
  45.  
  46. For example, a MULTIJOY user would add the following lines to his AUTOEXEC.BAT:
  47.  
  48. SET MULTIPATH=D:\MULTIJOY
  49. SET MULTICFG=MULTI007
  50. SET MULTIPORT=2
  51.  
  52. To try out a game on the computer of a friend who has no interface yet, one
  53. could type from the DOS prompt:
  54.  
  55. SET MULTIPATH=A:\JETFIGHT
  56. SET MULTICFG=KEYBOARD
  57.  
  58. You will find that most multi joystick games use the path provided by MULTIPATH
  59. to save the names of the players. This is very convenient as you don't have to
  60. enter all your friends' names again and again while you switch through the
  61. games during a gaming session.
  62.  
  63.  
  64. b) How the hardware of the interface works
  65. ------------------------------------------
  66.  
  67. Apart from some elements that are responsible for the power supply, the Multi
  68. Joystick Interface mainly consists of two multiplexors. The data lines D0 to D3
  69. of the Centronics port are used to provide the address for both multiplexors.
  70. Each of the multiplexors switches one of the joystick direction lines to it's
  71. output. The output of the first multiplexor is connected to Centronics BUSY,
  72.  the one of the second to Centronics PAPER EMPTY. By running through the
  73. (16) addresses $00 to $0F, 32 joystick switches can be read, enough for
  74. 6 joysticks.
  75.      To be precise, 2 switches more than enough. These switches are used for a
  76. second fire button for the first two joysticks. The extra buttons are
  77. available on pin 7 so that Sega, Amstrad and MSX joysticks work with the
  78. interface.
  79.      Pin 7 of the remaining four joystick ports is used to supply the joysticks
  80. with +5V (Atari/Commodore compatible). Some fancy autofire joysticks depend on
  81. this power supply. The power supply is also useful if you want to connect old
  82. Atari Trakballs (tm), though special software is required to utilize them.
  83. (If you are interested in this rather special application, contact us for some
  84. routines dealing with trackballs). It also should be possible to connect up to
  85. four Commodore type mouses to the interface, but we haven't tried that yet.
  86.      Because pin 7 is used for different purposes, it's important that your
  87. Amstrad joystick has a resistor of about 330 Ohms in line with the extra
  88. button. Though it's very probable that the joystick you want to use is
  89. equipped with this resistor, it's not guaranteed, and you could blow the fuse
  90. of your interface without it.
  91.  
  92.  
  93. c) How use the interface with your own programs
  94. -----------------------------------------------
  95.  
  96. After you've read b), this may read like a repetition: To read all joysticks
  97. once, write $00 to $0F to the printer port and read out it's status register
  98. immediately after writing each address. The status of the two joystick switches
  99. belonging to the address you wrote is returned via the PAPER EMPTY and the BUSY
  100. bit. On MSDOS computers, PAPER EMPTY (bit 5) is set and BUSY (bit 7) is cleared
  101. when the corresponding joystick switches are closed. To determine which
  102. joystick switch belongs to a given address, you need the table supplied by the
  103. MULTI007.CFG file. It reads like this:
  104.  
  105.     0  6 r 4 u
  106.     1  6 l 2 d
  107.     2  6 d 2 r
  108.     ...
  109.     15 5 f 3 l
  110.  
  111.     ^  ^ ^ ^ ^
  112.     |  | | | |action
  113.     |  | | |joystick on BUSY
  114.     |  | |action (left/right/up/down/fire/extra button ('*'))
  115.     |  |joystick on PE
  116.     |address
  117.  
  118. As config files are used to adapt the software to improvements of the hardware,
  119. it's a good idea not to hardcode the table but to read it from the CFG file
  120. when starting the program.
  121.  
  122. The files MINIJOY.PAS and MINIJOY.C are examples of basic modules for reading
  123. the Multi Joystick Interface. MULTIJOY.PAS has some extra features, the most
  124. useful being the emulation mode in wich you can use the keyboard to emulate the
  125. first two joysticks.
  126.  
  127.  
  128. d) How to use the MULTIJOY and MINIJOY modules with your own programs
  129. ---------------------------------------------------------------------
  130.  
  131. MULTIJOY.PAS and MINIJOY.PAS are Turbo Pascal units, MINIJOY.C is a Turbo C
  132. file which can be compiled and linked into your programs. To get information
  133. about the joysticks, your program has to call the GetAllJoyState routine
  134. regularly. GetAllJoyState saves the status of the joysticks in the JoyState
  135. record/struct. x, y, knopf and xtra depict the status of x axis, y axis, button
  136. (german knopf=english button) and extra button at the time of the call, the
  137. variables ending on -hit are set if the appropriate switches are closed now
  138. but were not closed at the time of the previous call of GetAllJoyState. (This
  139. is useful when you don't want a continuous movement but only a step whenever
  140. the joystick is pushed into any direction).
  141.       If you want to support joystick keyboard emulation, you must use MULTIJOY
  142. instead of MINIJOY. See e) for details.
  143.  
  144. A very, very basic example of MULTIJOY usage:
  145.  
  146. program multijoy_demo;
  147. (* minimal drawing program *)
  148.  
  149. uses crt, multijoy; (* joystick will be used for drawing *)
  150.  
  151. var x, y : integer; (* screen position *)
  152.  
  153. begin
  154.   x := 40;          (* center of screen *)
  155.   y := 12;
  156.   ClrScr;
  157.   repeat
  158.     GetAllJoyState;                  (* request status of joysticks         *)
  159.     x := x + JoyState [1].x;         (* x movement controlled by joystick 1 *)
  160.     y := y + JoyState [1].y;         (* y movement                          *)
  161.     GotoXY (x,y);
  162.     if JoyState [1].knopf then begin (* pen down when the knopf is pressed  *)
  163.       Write  ('X');
  164.       GotoXY (x,y);
  165.     end;
  166.     Delay (50);
  167.   until keypressed;
  168. end.
  169.  
  170.  
  171. e) Details of the emulation of joysticks using the keyboard
  172. -----------------------------------------------------------
  173.  
  174. If you don't have an interface yet and want to try out the games to see what
  175. awaits you, you can use the keyboard to emulate the first two joysticks.
  176.      Emulation mode is invoked by setting MULTICFG to KEYBOARD or another
  177. keyboard config file. The standard CFG file KEYBOARD uses the following keys:
  178.  
  179.      Joystick 1 (cursor keys)       Joystick 2
  180.  
  181. up            ^                         E
  182. left/right  <   >                     S   F
  183. down          v                         D
  184.  
  185. fire        CTRL                       TAB
  186.  
  187. MULTIJOY additionally has two procedures, EmulationOn and EmulationOff, that
  188. are necessary for the joystick emulation to work correctly. As MULTIJOY has to
  189. take control of the keyboard in emulation mode, the keyboard is not longer
  190. available for entering data or starting the program. To circumvene this
  191. problem, the game program has to switch the emulation off in the menu part and
  192. to switch it on again for the game part. If MULTIJOY is not in emulation mode,
  193. it ignores these switches.
  194.  
  195. Keyboard config files look like that:
  196.  
  197. keyboard              <- keyword KEYBOARD
  198. l 75                  <- joystick 1 left (cursor left here)
  199. r 77
  200. u 72                           ...
  201. d 80
  202. f 29                  <- joystick 1 fire (control here)
  203. l 31                  <- joystick 2 left
  204. r 33
  205. u 18                           ...
  206. d 32
  207. f 15                  <- joystick 2 fire
  208. ^ ^
  209. | | keyboard scancode
  210. | dummy character to remind humans of the expected sequence of keys
  211.  
  212.  
  213. f) How to contact us
  214. --------------------
  215.  
  216. You can contact us by email at
  217.  
  218.         incr@asterix.rz.tu-clausthal.de
  219.  
  220. or by snail mail at
  221.  
  222.         Christof Ruch
  223.         Rollplatz 19
  224.         38678 Clausthal-Zellerfeld
  225.         Germany
  226.  
  227.  
  228. g) How to get the multijoy games
  229. --------------------------------
  230.  
  231. Don't miss the multijoy games, they are not included in this package. You can
  232. find them at
  233.  
  234.         ftp.tu-clausthal.de     /pub/msdos/games/multijoy
  235.  
  236. For those of you without ftp access, there is also a mail server. Just mail
  237. a message with 'help' as body to
  238.  
  239.         mail-server@ftp.tu-clausthal.de
  240.  
  241. to see how it works.
  242.  
  243. If you plan to spread the multijoy software you have written, you should upload
  244. a copy to this server (/pub/msdos/incoming). This way, all multijoy software
  245. will be available at one place. Multijoy enthusiasts will find it easy to keep
  246. track of the latest developments.
  247.  
  248.  
  249. h) Credits
  250. ----------
  251.  
  252. The Multi Joystick Interface was conceived and realized by:
  253.  
  254.         Friedrich Fiege         design of first interface
  255.         Peter Fiege             realization of the first interface,
  256.                                 chemical engeneering
  257.         Felix Meyer             many contributions of great value
  258.         Christof Ruch           original idea and restless production of
  259.                                 software
  260.         Henning Ruch            basic Multijoy software and PCB design
  261.         Peter Waldheim          original idea and first Multijoy game, TRON,
  262.                                 which existed long before our hardware
  263.  
  264.